<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.backupDB.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.frame.util.Config;" %>


<%
request.setCharacterEncoding("UTF-8");
/***********************基本信息***********************/
Config cfg = new Config("jdbc.properties");
cfg.init();
String dbName = cfg.getString("dbname");
Backup backup = new Backup();

/***********************查找数据库中所有的表***********************/


    List tableList = new ArrayList();
	String iStart = "0";
	int limit = 20;
	 if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	//if(request.getParameter("s_pay_name")!=null ){
	//    String keyword = request.getParameter("s_pay_name");
	//    tableList = backup.getDatabyKey(dbName,Integer.parseInt(iStart),limit,keyword);
	//}else{
	     tableList = backup.selAllTableInfo(dbName,Integer.parseInt(iStart),limit);
	//}
	int tableSize = 0;
	if(tableList != null && tableList.size() > 0){
		tableSize = tableList.size();
	}
	int counter = backup.selAllTableCounts(dbName);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?iStart=",Integer.parseInt(iStart),limit);
%>

<html>
  <head>
    
    <title>数据库备份还原</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="backup.js"></script> 
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>	
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>数据库备份还原管理</h1>
			</td>
			<td>
				
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left">
				数据库表名:<input name="s_pay_name" id="s_pay_name" type="text" />
			
			<input name="searchInfo" type="button" value="查询" onclick="return search();"/></td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
						<tr>
						<th colspan="4">
							<br/><input type="button"  class="buttoncss" value="备份所选" class="submitButton" onclick="operSel(1)"/>&nbsp;
							<input type="button"  class="buttoncss" value="还原所选" class="submitButton" onclick="operSel(2)"/>&nbsp;
							<input type="button"  class="buttoncss" value="备份数据库" class="submitButton" onclick="operation(1,'<%=dbName%>')"/>&nbsp;
							<input type="button"  class="buttoncss" value="还原数据库" class="submitButton" onclick="window.location.href='restoreIndex.jsp'"/>
						</th>
					</tr>	
					
		<tr><td>
		<br/><%=pageString %></td></tr>
	</table>

	
	<% 
		int listsize = 0;
		if(tableList!=null && tableList.size()>0){
			listsize = tableList.size();
	%>
	
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="89%">
				
			</td>

			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
		  	
		  	<th>数据库表名</th>
		  	
		  	<th>记录数</th>

			<th width="20%">操作</th>
		</tr>
		
		
		<% 
		for(int i=0;i<tableList.size();i++){
			Hashtable map = (Hashtable)tableList.get(i);
			String tableName = "",tableCounts="0";
			if(map.get("table_name")!=null){
				tableName = map.get("table_name").toString();
			}
			if(map.get("table_size")!=null){
				tableCounts = map.get("table_size").toString();
			}  

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=tableName%>" /></td>
		
		  	


		  	
		  	<td><%=tableName%></td>
		  	<td><%=tableCounts%></td>
		  	
			
	  		<td width="10%">
				<a href="javascript:operation(1,'<%=tableName%>')">备份</a> 
				| 
				<a href="javascript:operation(2,'<%=tableName%>')">还原 </a>
				| 
				<a href="showTable.jsp?table_name=<%=tableName%>">结构</a>			
			</td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="89%">
				
			</td>

			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="table_name" id="table_name" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="" />
	  </form>
</body>

</html>
